#!/usr/bin/python
#  This is part of Scopia Visual Framework
#
#  Root opengl adaptors module
#
#  Copyright (C) 2008  Scopia Visual Interfaces Systems 
#                      http://www.scopia.es
#
#  author: Alejandro Conty
#  contributors:
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

import time

class adaptor_t(object):
    """Base class for any adaptor that gives an openGL window. It must
       host an opengl application (glContext_t derivate) and dispatch
       events to it."""
    def __init__(self):
        self.frameCount = 0
        self.lastFrameTime = time.time()

    def countFrames(self):
        self.frameCount += 1
        if self.frameCount == 100:
            nowtime = time.time()
            print 'Frames per second = ', float(self.frameCount) / (nowtime - self.lastFrameTime)
            self.lastFrameTime = nowtime
            self.frameCount = 0
